<?php

namespace app\models\group;

use Yii;

/**
 * This is the model class for table "group_list".
 *
 * @property int $id
 * @property int $group_id 成团id
 * @property float $add 新增加多少
 * @property float $total
 * @property string $create_time
 */
class GroupList extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'group_list';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['group_id'], 'integer'],
            [['add', 'total'], 'number'],
            [['create_time'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'group_id' => 'Group ID',
            'add' => 'Add',
            'total' => 'Total',
            'create_time' => 'Create Time',
        ];
    }

    public function beforeSave($insert)
    {
        if (parent::beforeSave($insert)) {
            $time = date('Y-m-d H:i:s');
            if ($insert) {
                $this->create_time = $time;
            }
            return true;
        }
        return false;
    }
}
